package com.example.drug.mapper;

import cn.hutool.core.date.DateTime;

import com.example.drug.dto.resp.DiagnosisListRsp;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @ClassName PatientMapper
 * @Author wengjt
 * @Date 2021/4/918:41
 * @Description
 **/
@Component
public interface PatientMapper {

    @Select("select b.group_name_nvarchar from doctor_group_patients a"
            +" inner join doctor_group_main b on a.gid_bigint = b.gid_bigint"
            +" where a.pid_bigint = #{PID} and b.dc_id_bigint = #{DCID}"
            +" LIMIT 1")
    String getGroupName(@Param("PID") long PID, @Param("DCID") long DCID);


    @Select("SELECT " +
            "c.`name` AS Name,c.title AS Title,d.name_nvarchar AS dName,a.receive_time_datetime AS ReceiveTime ," +
            " a.order_no_nvarchar AS OrderNO ,b.first_tinyint AS First " +
            "FROM order_main a " +
            "INNER JOIN order_patients_info b " +
            "ON(a.order_no_nvarchar=b.order_no_nvarchar) " +
            "INNER JOIN doctor_base_info c " +
            "ON (a.dc_id_bigint=c.dc_id) " +
            "INNER JOIN h_hospital_department d " +
            "ON(c.depart_id=d.id_bigint) " +
            "WHERE a.pid_bigint=#{pid} " +
            "AND a.system_status_tinyint=2 " +
            "AND oc_status_tinyint !=0 " +
            "AND a.receive_time_datetime>#{dateTime}  " +
            "ORDER BY a.receive_time_datetime DESC ")
    List<DiagnosisListRsp> queryDiagnosisListByPid(@Param("pid") Long pid, @Param("dateTime") Date dateTime);
}
